home *** CD-ROM | disk | FTP | other *** search
- /* Pan.rexx ver .2 27 April 2001 */
- /* This script pans a large image, building frames for video usage.*/
- /* First, see if PPaint is running */
- /* trace results */
-
- PPPORT = 'PPAINT'
-
- IF ~SHOW('p', PPPORT) then do
- if exists('PPaint:PPaint') then do
- Address command 'Run >NIL: PPaint:PPaint'
- DO 30 while ~show('p',PPPORT)
- address command 'Wait >NIL: 1 sec'
- END
- end
- else do
- Say "Personal Paint could not be loaded."
- Exit 10
- end
- end
-
- if ~show('p', PPPORT) then do
- say 'Personal Paint Rexx port could not be opened'
- exit 10
- end
- address value PPPORT
- Options results
- options failat 10000
-
- /* Identify sourcefile & set up buffers */
-
- say 'What is your sourcefile?'
- pull SourceFile
-
- say 'What is your destination directory'
- pull DestPath
-
- /* say 'What is your destination image size?' */
- /* pull DestX DestY */
-
- /* Hard coded until we figure out how to force it! */
-
- DestX = 640
- DestY = 464
-
- GetFileFormat 'FILE' Sourcefile 'FULL'
-
- String = Result
-
- Error = RC
- Call ErrorCode()
-
- ImageType = word(String,1)
- ImageWidth = word(String,2)
- ImageHeight = word(String,3)
- ImageColors = word(String,4)
-
- /* Convert number of colors to bitplanes */
-
- If ImageColors =16777216
- then ColorSize = 24
- else NOP
- If ImageColors = 256
- then ColorSize = 8
- else NOP
- If ImageColors = 128
- then ColorSize = 7
- else NOP
- If ImageColors = 64
- then ColorSize = 6
- else NOP
- If ImageColors = 32
- then ColorSize = 5
- else NOP
- If ImageColors = 16
- then ColorSize = 4
- else NOP
- If ImageColors = 8
- then Colorsize = 3
- else NOP
- If ImageColors = 4
- then Colorsize = 2
- else NOP
- If ImageColors = 2
- then ColorSize = 1
- else NOP
-
- /* See if the destination image is too big */
-
- If DestX > ImageWidth then do
- say 'Destination wider than source. Aborted'
- Say 'ImageWidth is' ImageWidth 'Destination is' DestX
- Exit
- end
- else If DestY > ImageHeight then do
- say 'Destination taller than source. ABorted.'
- say 'ImageHeight is' ImageHeight 'Destination is' DestY
- Exit
- end
- else NOP
-
- Say 'What is the starting center point for the pan (x/y)?'
- pull StartX StartY
-
- If ( StartX - DestX/2 ) < 0 then do
- Say 'X starting point places you outside the image. Aborted.'
- Exit
- end
- else If ( StartY - DestY/2 ) < 0 then do
- Say 'Y starting point places you outside the image. Aborted.'
- Exit
- End
- else NOP
-
- Say 'What is the ending center point for the pan (x/y)?'
- pull EndX EndY
-
- If EndX + (DestX/2) > ImageWidth then do
- say 'X ending point places you outside the image. Aborted.'
- Exit
- End
- else If EndY + (DestY/2) > ImageHeight then do
- Say 'Y ending point places you outside the image. Aborted.'
- Exit
- End
- else NOP
-
- Say 'How many frames in this video sequence?'
- Pull Frames
- Error = RC
- Call ErrorCode()
-
- Set 'FORCE "SCREENW=640" "SCREENH=464" "Colors=256"'
- Error = RC
- Call ErrorCode()
-
- LoadBrush 'FILE' SourceFile
- Error = RC
- Call ErrorCode()
-
- UseBrushPalette
- Error = RC
- Call ErrorCode()
-
- SetBrushHandle 'OffsetX' 0 'OffsetY' 0
- Error = RC
- Call ErrorCode()
-
- ClearImage
- Error = RC
- Call ErrorCode()
-
- /* Now pan through the bitmap */
- BrushX = StartX - 320
- BrushY = StartY - 232
- k = 1
- /* First, handle the case of a horizontal pan */
-
- If StartY = EndY then do
- DeltaX = (EndX - StartX)/Frames
- do i for Frames
- ClearImage
- Error = RC
- Call ErrorCode()
- SetBrushHandle 'OffsetX' BrushX 'OffsetY' BrushY
- Error = RC
- Call ErrorCode()
- PutBrush 'X' 0 'Y' 0
- Error = RC
- Call ErrorCode()
- Temp = BrushX + DeltaX
- BrushX = Trunc(Temp,0)
- Call SaveFile()
- End
- End
-
- /* Next, address the case of a vertical pan */
-
- Else If StartX = EndX then do
- DeltaY = (EndY-StartY)/Frames
- do i for Frames
- ClearImage
- Error = RC
- CAll ErrorCode()
- SetBrushHandle 'OffsetX' BrushX 'OffsetY' BrushY
- Error = RC
- Call ErrorCode()
- PutBrush 'X' 0 'Y' 0
- Temp = (BrushY + DeltaY)
- BrushY = Trunc(Temp,0)
- Call SaveFile()
- End
- End
-
- /* Finally, handle the case where the pan follows an angle */
-
- Else do
- Slope = (StartY-EndY)/(StartX - EndX)
- DeltaX = (EndX - StartX)/Frames
- XIncr = 0
- do i for Frames
- Clear Image
- Error = RC
- Call ErrorCode()
- SetBrushHandle 'OffsetX' BrushX 'OffsetY' BrushY
- Error = RC
- Call ErrorCode()
- PutBrush 'X' 0 'Y' 0
- Error = RC
- Call ErrorCode()
- Temp = XIncr + DeltaX +.5
- XIncr = Trunc(Temp,0)
- YIncr = XIncr * Slope
- Temp = BrushY + YIncr
- BrushY = Temp
- Temp = BrushX + XIncr
- BrushX = Temp
- Call SaveFile()
- End
- End
- Exit
-
- /* End of Main Program. The supporting players follow */
-
- */ SaveFile writes the current image to a picxxxx file in the path */
- SaveFile: M = DestPath||'/pic0'
- j = k
- /* Handle 100's digit */
- j1 = Trunc(j/100,0)
- Call Digit()
- if J > 99 then do
- temp = J-trunc(j/100,0)*100
- J = temp
- end
- else NOP
- /* Handle 10's digit */
- j1 = Trunc(j/10,0)
- Call Digit()
- if J > 9 then do
- temp = J-trunc(j/10,0)*10
- j = temp
- end
- else NOP
- /* Handle 1's digit */
- j1 = Trunc(J,0)
- Call Digit()
- temp = k + 1
- k = temp
- /* Tacile Feedback for the human watching */
- Say M
- SaveImage 'File' M
- Error = RC
- Call ErrorCode()
- Return
-
- /*Digit adds each digit to the end of the file name */
-
- Digit: If J1 = 1 then M1 = M||'1'
- else if J1 = 2 then M1 = M||'2'
- else if J1 = 3 then M1 = M||'3'
- else if J1 = 4 then M1 = M||'4'
- else if J1 = 5 then M1 = M||'5'
- else if J1 = 6 then M1 = M||'6'
- else if J1 = 7 then M1 = M||'7'
- else if J1 = 8 then M1 = M||'8'
- else if J1 = 9 then M1 = M||'9'
- else M1 = M||'0'
- M = M1
- Return
-
- /* Error Code types out the error message associated with any error code */
- /* This routine is always called whenever anything of significance is done*/
- /* By an AREXX call to PPaint. Errors in the program you are reading are */
- /* assumed to have been caught, and are not trapped - trapping is */
- /* By the host AREXX environment */
-
- /* All defined PPaint AREXX error codes are trapped, even though it may */
- /* Very unlikely some of these situations could occur as the program is */
- /* being used here */
-
-
-
- Errorcode: If Error > 0 then do
- If error = 1 then msg='Program not found'
- else nop
- If error = 2 then msg='Execution halted'
- else nop
- If error = 3 then msg='Insufficient memory'
- else nop
- If error = 4 then msg='Invalid character'
- else nop
- If Error = 5 then msg='Operation cancelled by user'
- else nop
- If Error = 30 then msg='Unknown command'
- else nop
- If error = 31 then msg='required argument missing'
- else nop
- If error = 32 then msg='Too many arguments'
- else nop
- If error = 33 then msg='Incompatible options'
- else nop
- If error = 34 then msg='Generic error'
- else nop
- If error = 35 then msg='Error during file I/O'
- else nop
- If error = 36 then msg='File could not be opened'
- else nop
- If error = 37 then msg='Not enough memory'
- else nop
- If error = 38 then msg='File format not recognized'
- else nop
- If error = 39 then msg='File does not contain the required data.'
- else nop
- If error = 40 then msg='Error in file data'
- else nop
- If error = 41 then msg='Unable to load this type of image'
- else nop
- If error = 42 then msg='Decryption impossible'
- else nop
- If error = 43 then msg='Warning:partial load'
- else nop
- If error = 44 then msg='Printer device cannot be opened'
- else nop
- If error = 45 then msg='Error during printer output'
- else nop
- If error = 46 then msg='Unknown format'
- else nop
- If error = 47 then msg='Unknown format option'
- else nop
- If error = 48 then msg='Unknown setting'
- else nop
- If error = 49 then msg='Numerical argument required'
- else nop
- If error = 50 then msg='Value out of range/illegal value'
- else nop
- If error = 51 then msg='no animation to work on'
- else nop
- If error = 52 then msg='Unknown image processing filter'
- else nop
- If error = 53 then msg='User brush needed'
- else nop
- If error = 54 then msg='Anim brush needed'
- else nop
- If error = 55 then msg='The command cannot process anim-brushes'
- else nop
- If error = 56 then msg='Font could not be opened'
- else nop
- If error = 57 then msg='No unused brushes available'
- else nop
- If error = 58 then msg='No undo/redo available'
- else nop
- If error = 59 then msg='Unknown or unsupported video mode'
- else nop
- say msg
- End
- else nop
- Return
-
- /* That's All, Folks! */
-
- Exit
-